home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6298 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  34 lines

  1. Newsgroups: comp.lang.c
  2. Path: thinkage.on.ca!atbowler
  3. From: atbowler@thinkage.on.ca (Alan Bowler)
  4. Subject: Re: How do I sort a large Array?
  5. Message-ID: <Dn8vI4.D8D@thinkage.on.ca>
  6. Sender: news@thinkage.on.ca
  7. Organization: Thinkage Ltd.
  8. References: <4g1kr1$kg1@rznews.rrze.uni-erlangen.de> <4giec7INN1sc@keats.ugrad.cs.ubc.ca>
  9. Date: Fri, 23 Feb 1996 19:58:52 GMT
  10.  
  11. In article <4giec7INN1sc@keats.ugrad.cs.ubc.ca> c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) writes:
  12. >In article <4g1kr1$kg1@rznews.rrze.uni-erlangen.de>,
  13. >Matthias Gessl (CIP 95) <msgessl@cip.informatik.uni-erlangen.de> wrote:
  14. > >How do I sort a large array of char-arrays, which is too large to fit in
  15. > >memory?
  16. > >For example I want to sort an array of >10000 elements, but have only RAM
  17. > >for about 500 elements
  18. > >
  19. > >Many thanks in advance.
  20. >
  21. >You sort from one file to another. Create N sorted segments (files) that are as
  22. >large as possible, using available memory. Then merge them together.
  23. >
  24. >A good textbook on filesystems and database management should outline
  25. >techniques for sorting large files using a polyphase merge.
  26.  
  27. Before you go to all that work, first check the documentation for
  28. utility programs on your system.  There is usually a utility 
  29. sort that will do a disk based sort for you.  On the older mainframe
  30. systems the utility sorts will even have a method of writing your
  31. own compare code although that is very seldom needed.  Internally these
  32. will use some form of merge sort (polyphase, cascade etc), but you
  33. can ignore that and treat it as a black box.
  34.